import {
  AutoIncrement,
  Column,
  DataType,
  Model,
  PrimaryKey,
  Table,
} from 'sequelize-typescript';

@Table({
  tableName: 'user',
  indexes: [{ name: 'open_id', fields: ['open_id'] }],
})
export class User extends Model {
  @PrimaryKey
  @AutoIncrement
  @Column({
    type: DataType.INTEGER,
    allowNull: false,
    comment: '用户id',
  })
  id: number;

  //用户名称
  @Column({
    type: DataType.STRING(255),
    comment: 'openId',
    unique: true,
  })
  openId: string;

  @Column({
    type: DataType.STRING(255),
    comment: '用户名',
  })
  account: string;

  @Column({
    type: DataType.STRING(255),
    comment: '昵称',
  })
  nickName: string;

  @Column({
    type: DataType.STRING(255),
    comment: '来源',
  })
  origin: string;

  @Column({
    type: DataType.STRING(255),
    comment: '头像',
  })
  avatar: string;

  @Column({
    type: DataType.STRING(10),
    comment: '类型',
  })
  type: string;

  @Column({
    type: DataType.STRING(255),
    comment: '密码',
  })
  password: string;
}
